public class Draw
{
    private final int height;

    // 构造方法
    public Draw(int height)
    {
        this.height = height;
    }

    // 绘制三角形
    public void drawTriangle()
    {
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < height - i - 1; j++)
            {
                System.out.print(" ");
            }
            for (int k = 0; k < 2 * i + 1; k++)
            {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制矩形
    public void drawRectangle()
    {
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < height; j++)
            {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制正方形
    public void drawSquare()
    {
        drawRectangle();
    }

    // 绘制平行四边形
    public void drawParallelogram()
    {
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < i; j++)
            {
                System.out.print(" ");
            }
            for (int k = 0; k < height - i; k++)
            {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 主方法，用于创建Draw对象并绘制图形
    public static void main(String[] args)
    {
        Draw draw = new Draw(5);

        System.out.println("三角形：");
        draw.drawTriangle();
        System.out.println("矩形：");
        draw.drawRectangle();
        System.out.println("正方形：");
        draw.drawSquare();
        System.out.println("平行四边形：");
        draw.drawParallelogram();
    }
}